from fastapi import APIRouter
from api.api_v1.endpoints import modules
import importlib


def build_router():
    apis = APIRouter()
    for name in modules:
        if not name.startswith('_'):
            s = importlib.import_module('api.api_v1.endpoints.{}'.format(name))
            apis.include_router(s.router, prefix='/{}'.format(name), tags=[name])

    return apis


api_router = build_router()
